<template>
  <el-container>
    <el-header style="height: 40px">
      <el-button type="primary" icon="el-icon-plus" style="float: right">
        新建
      </el-button>
    </el-header>
    <el-main>
      <el-row :gutter="10">
        <el-col :span="8">
          <div class="grid-content bg-purple">
            <el-card :body-style="{ padding: '0px' }">
              <img src="/static/right.jpg" class="image" />
              <div style="padding: 2px">
                <span style="text-align: right">好吃的汉堡啊大多数</span>
                <div class="bottom clearfix">
                  <el-button
                    type="primary"
                    size="mini"
                    icon="el-icon-edit"
                    round
                  >
                    编辑
                  </el-button>
                  <el-button
                    type="success"
                    size="mini"
                    icon="el-icon-check"
                    round
                  >
                    发布
                  </el-button>
                  <el-button
                    type="danger"
                    size="mini"
                    icon="el-icon-download"
                    round
                  >
                    下架
                  </el-button>
                </div>
              </div>
            </el-card>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="grid-content bg-purple-light">
            <el-card :body-style="{ padding: '0px' }">
              <img src="/static/right.jpg" class="image" />
              <div style="padding: 2px">
                <span>好吃的汉堡啊大多数</span>
                <div class="bottom clearfix">
                  <el-button
                    type="primary"
                    size="mini"
                    icon="el-icon-edit"
                    round
                  >
                    编辑
                  </el-button>
                  <el-button
                    type="success"
                    size="mini"
                    icon="el-icon-check"
                    round
                  >
                    发布
                  </el-button>
                  <el-button
                    type="danger"
                    size="mini"
                    icon="el-icon-download"
                    round
                  >
                    下架
                  </el-button>
                </div>
              </div>
            </el-card>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="grid-content bg-purple">
            <el-card :body-style="{ padding: '0px' }">
              <img src="/static/right.jpg" class="image" />
              <div style="padding: 2px">
                <span>好吃的汉堡啊大多数</span>
                <div class="bottom clearfix">
                  <el-button
                    type="primary"
                    size="mini"
                    icon="el-icon-edit"
                    round
                  >
                    编辑
                  </el-button>
                  <el-button
                    type="success"
                    size="mini"
                    icon="el-icon-check"
                    round
                  >
                    发布
                  </el-button>
                  <el-button
                    type="danger"
                    size="mini"
                    icon="el-icon-download"
                    round
                  >
                    下架
                  </el-button>
                </div>
              </div>
            </el-card>
          </div>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="8">
          <div class="grid-content bg-purple">
            <el-card :body-style="{ padding: '0px' }">
              <img src="/static/right.jpg" class="image" />
              <div style="padding: 2px">
                <span>好吃的汉堡啊大多数</span>
                <div class="bottom clearfix">
                  <el-button
                    type="primary"
                    size="mini"
                    icon="el-icon-edit"
                    round
                  >
                    编辑
                  </el-button>
                  <el-button
                    type="success"
                    size="mini"
                    icon="el-icon-check"
                    round
                  >
                    发布
                  </el-button>
                  <el-button
                    type="danger"
                    size="mini"
                    icon="el-icon-download"
                    round
                  >
                    下架
                  </el-button>
                </div>
              </div>
            </el-card>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="grid-content bg-purple-light">
            <el-card :body-style="{ padding: '0px' }">
              <img src="/static/right.jpg" class="image" />
              <div style="padding: 2px">
                <span>好吃的汉堡啊大多数</span>
                <div class="bottom clearfix">
                  <el-button
                    type="primary"
                    size="mini"
                    icon="el-icon-edit"
                    round
                  >
                    编辑
                  </el-button>
                  <el-button
                    type="success"
                    size="mini"
                    icon="el-icon-check"
                    round
                  >
                    发布
                  </el-button>
                  <el-button
                    type="danger"
                    size="mini"
                    icon="el-icon-download"
                    round
                  >
                    下架
                  </el-button>
                </div>
              </div>
            </el-card>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="grid-content bg-purple">
            <el-card :body-style="{ padding: '0px' }">
              <img src="/static/right.jpg" class="image" />
              <div style="padding: 2px">
                <span>好吃的汉堡啊大多数</span>
                <div class="bottom clearfix">
                  <el-button
                    type="primary"
                    size="mini"
                    icon="el-icon-edit"
                    round
                  >
                    编辑
                  </el-button>
                  <el-button
                    type="success"
                    size="mini"
                    icon="el-icon-check"
                    round
                  >
                    发布
                  </el-button>
                  <el-button
                    type="danger"
                    size="mini"
                    icon="el-icon-download"
                    round
                  >
                    下架
                  </el-button>
                </div>
              </div>
            </el-card>
          </div>
        </el-col>
      </el-row>
    </el-main>
  </el-container>
</template>

<script>
  import { getAlarmLogList, saveAlarmReason } from '@/api/alarm'
  //import Edit from './components/RoleManagementEdit'

  export default {
    name: 'RoleManagement',
    //components: { Edit },
    data() {
      return {
        list: null,
        listLoading: true,
        layout: 'total, sizes, prev, pager, next, jumper',
        total: 0,
        selectRows: '',
        elementLoadingText: '正在加载...',
        queryForm: {
          pageNo: 1,
          pageSize: 10,
          permission: '',
        },
      }
    },
    created() {
      //this.fetchData()
    },
    methods: {
      setSelectRows(val) {
        this.selectRows = val
      },
      waitConfirm(row) {
        if (row) {
          this.$refs['edit'].showEdit(row)
        } else {
          this.$refs['edit'].showEdit()
        }
      },
      handleDelete(row) {
        if (row.own_id) {
          this.$baseConfirm('你确定要删除当前项吗', null, async () => {
            const { msg } = await doDelete({ id: row.own_id })
            this.$baseMessage(msg, 'success')
            this.fetchData()
          })
        } else {
          if (this.selectRows.length > 0) {
            const ids = this.selectRows.map((item) => item.own_id).join()
            this.$baseConfirm('你确定要删除选中项吗', null, async () => {
              const { msg } = await doDelete({ id: ids })
              this.$baseMessage(msg, 'success')
              this.fetchData()
            })
          } else {
            this.$baseMessage('未选中任何行', 'error')
            return false
          }
        }
      },
      handleSizeChange(val) {
        this.queryForm.pageSize = val
        this.fetchData()
      },
      handleCurrentChange(val) {
        this.queryForm.pageNo = val
        this.fetchData()
      },
      queryData() {
        this.queryForm.pageNo = 1
        this.fetchData()
      },
      async fetchData() {
        this.listLoading = true
        const { data } = await getAlarmLogList(this.queryForm)
        this.list = data.list
        this.total = data.pageInfo.data.totalRows
        setTimeout(() => {
          this.listLoading = false
        }, 300)
      },
    },
  }
</script>
<style scoped>
  .handle-box {
    margin-bottom: 20px;
    float: left;
  }
  .handle-opt-button {
    float: right;
  }
  .handle-select {
    width: 120px;
  }

  .handle-input {
    width: 300px;
    display: inline-block;
  }
  .table {
    width: 100%;
    font-size: 14px;
  }
  .red {
    color: #ff0000;
  }
  .mr10 {
    margin-right: 10px;
  }
  .table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
  }
  .el-header,
  .el-footer {
    text-align: right;
    line-height: 30px;
  }

  .el-aside {
    background-color: #d3dce6;
    color: #333;
    text-align: center;
    line-height: 60px;
  }

  .el-main {
    background-color: #e9eef3;
    color: #333;
    text-align: center;
    line-height: 60px;
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 60px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 80px;
  }
  .image {
    width: 100%;
    display: block;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: '';
  }

  .clearfix:after {
    clear: both;
  }

  .el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
</style>
